/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package protocol;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import server.managerServer.executors.ExecutorConnect;

/**
 *
 * @author radu
 */
public class MessageConnectReq extends Message {

    private String email = "";
    private String password = "";

    public MessageConnectReq(Element root) {
        NodeList emailNodes = root.getElementsByTagName("email");
        if (emailNodes.getLength() == 1) {
            Node emailNode = emailNodes.item(0);
            if (emailNode.getNodeType() == Node.ELEMENT_NODE) {
                Element emailElem = (Element) emailNode;
                email = emailElem.getTextContent();
            }
        }
    }

    public MessageConnectReq(String email, String password) {
        this.email = email;
        this.password = password;
    }

    @Override
    public String toString() {
        return "<connect><email>"+email+"</email><passwd>"+password+"</passwd></connect>\r\n";
    }

    @Override
    public Executor getServerExecutor() {
        return new ExecutorConnect(this);
    }

    public String getEmail() {
        return email;
    }

    public String getPassword() {
        return password;
    }
    
    
    
    
}